﻿<UserControl x:Class="DocumentManagement.Views.ShowItemDocumentOutUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:DocumentManagement.ViewsModels"
             xmlns:converter="clr-namespace:DocumentManagement.Converters"
           
             mc:Ignorable="d" 
             d:DesignHeight="768" d:DesignWidth="1024" Background="#6EFFAE00">
    <UserControl.Resources>
        <vm:ShowItemDocumentOutViewsModel x:Key="showItemDocumentOutViewsModel"/>
        <converter:DateConverter x:Key="dateConverter"/>
        <converter:TextSpeedConverter x:Key="textSpeedConverter"/>
        <converter:TextActionConverter x:Key="textActionConverter"/>
        <ContextMenu x:Key="MyContextMenu">
            <MenuItem Header="เพิ่มหนังสือออก" Name="addOUTDocMenu" Click="addOUTDocMenu_Click" />
            <!--<MenuItem Header="สร้างหนังสือออก" Name="CreateOUTDocMenu" Click="CreateOUTDocMenu_Click" />-->
            <MenuItem Header="แก้ไขหนังสือออก" Name="editOUTDocMenu" Click="editOUTDocMenu_Click" />
            <MenuItem Header="ลบหนังสือออก" Name="deleteOUTDocMenu" Click="deleteOUTDocMenu_Click" />
        </ContextMenu>
    </UserControl.Resources>
  
                <Grid  Margin="10,10,12,29" DataContext="{Binding Source={StaticResource showItemDocumentOutViewsModel}}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="35" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <StackPanel Height="35" Name="stackPanel2" Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock FontSize="16" Height="23" Margin="0,5,0,0" Name="textBlock2" Text="ค้นหาข้อมูลหนังสือออก" TextAlignment="Center" VerticalAlignment="Center" Width="202" FontFamily="Tahoma" FontWeight="Bold" />
                    </StackPanel>
                    <StackPanel Grid.Row="1" Height="30" Name="stackPanel3" Orientation="Horizontal">
                        <TextBlock FontSize="14" Height="23" Name="textBlock4" Text="เลขที่หนังสือ/ชื่อเรื่อง :" TextAlignment="Right" Width="150" FontFamily="Tahoma" FontWeight="Normal" />
                        <TextBox FontSize="14" Height="23"  Margin="10,0,0,0" Name="SendCodeOrTitleTextBox" Width="298" KeyUp="SendCodeOrTitleTextBox_KeyUp" FontFamily="Tahoma" FontWeight="Normal" />
                        <TextBlock FontSize="14" Height="21" Name="textBlock6" Text="จากวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                        <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="FromDatePicker"  Width="115" SelectedDateChanged="FromDatePicker_SelectedDateChanged" FontFamily="Tahoma" FontWeight="Normal" />
                        <TextBlock FontSize="14" Height="21" Name="textBlock7" Text="ถึงวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                        <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="ToDatePicker"  Width="115" SelectedDateChanged="ToDatePicker_SelectedDateChanged" FontFamily="Tahoma" FontWeight="Normal" />
                    </StackPanel>
        <DataGrid AutoGenerateColumns="False" FontSize="14" Grid.Row="2" IsReadOnly="True" Margin="0,5,0,0" Name="ShowSendDataGrid" ContextMenu="{Binding Source={StaticResource MyContextMenu}}" ItemsSource="{Binding Path=MySendICV, Mode=TwoWay}" SelectedItem="{Binding Path=MySelectedEditItemSend, Mode=TwoWay}" AlternatingRowBackground="#6EFFAE00" FontFamily="Tahoma" FontWeight="Normal">
         
            <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Path=CreateSendID, Mode=TwoWay}" Header="รหัส" />
                <DataGridTextColumn Binding="{Binding Path=CreateSendCode, Mode=TwoWay}" Header="เลขที่ในหนังสือออก" />
                <DataGridTextColumn Binding="{Binding Path=CreateSendDate, Mode=TwoWay, StringFormat=\{0:d\}, Converter={StaticResource dateConverter}}" Header="วันที่ออกหนังสือ" />
               
                <DataGridTextColumn Binding="{Binding Path=Division_FromDivision.ThaiName, Mode=TwoWay}" Header="จากหน่วยงาน" />
                            <DataGridTextColumn Binding="{Binding Path=Division_ToDivision.ThaiName, Mode=TwoWay}" Header="ถึงหน่วยงาน" />
                            <DataGridHyperlinkColumn Binding="{Binding Path=Title, Mode=TwoWay}" Header="ชื่อเรื่อง">
                                <DataGridHyperlinkColumn.ElementStyle>
                                    <Style>
                                        <EventSetter Event="Hyperlink.Click" Handler="DG_Hyperlink_Click" />
                                    </Style>
                                </DataGridHyperlinkColumn.ElementStyle>
                            </DataGridHyperlinkColumn>
                <DataGridTextColumn Binding="{Binding Path=Speed, Mode=TwoWay, Converter={StaticResource textSpeedConverter}}" Header="ชั้นความเร็ว" >
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <Trigger Property="Text" Value="ปกติ">
                                    <Setter Property="Foreground" Value="Black"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วน" >
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วนมาก">
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วนที่สุด">
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                            </Style.Triggers>

                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Binding="{Binding Path=Action, Mode=TwoWay, Converter={StaticResource textActionConverter}}" Header="การปฏิบัติ" />
                            <DataGridTextColumn Binding="{Binding Path=Description, Mode=TwoWay}" Header="หมายเหตุ" />
                            <DataGridTextColumn Binding="{Binding Path=LogID, Mode=TwoWay}" Header="ผู้บันทึกรายการ" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
    
</UserControl>
